import { CopyInfoPanelBase } from "../CopyInfoPanelBase";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GuildEliteCopyCondition } from "./GuildEliteCopyCondition";
import { SGuildEliteCopyDetail } from "../../../../../Message/Public/SGuildEliteCopyDetail";
import { CopyConfig } from "../../../resource/CopyConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { GuildEliteConfig } from "../config/GuildEliteConfig";
import { Cache } from "../../../cache/Cache";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { MsgManager } from "../../../manager/MsgManager";
import { SecTimerView } from "../../common/SecTimerView";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class GuildEliteCopyInfoPanel
    
    export  class GuildEliteCopyInfoPanel extends CopyInfoPanelBase
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super(arg1);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tfYel = new GTextFormat(FontUtil.defaultName, 12, 16776960, true);
            this._tfRed = new GTextFormat(FontUtil.defaultName, 12, 16711680, true);
            this._time = ObjCreate.createSecTimeView(Language.getString(60617), _left, 10, 240, 20, _bodySp, this._tfYel);
            this._time.filters = [FilterConst.glowFilter];
            this._time.mouseEnabled = false;
            this._playerNum = ObjCreate.createGTextField("", _left, 30, 240, 20, _bodySp);
            this._playerNum.mouseEnabled = false;
            this._backToHell = ObjCreate.createGTextField("", _left, 30, 240, 20, _bodySp, new GTextFormat(FontUtil.defaultName, 12, GlobalStyle.color6Uint, null, null, true, null, null, flash.text.TextFormatAlign.RIGHT));
            this._backToHell.htmlText = "<a href=\'event: 0\'>" + Language.getString(60629) + "</a>";
            this._backToHell.addEventListener(flash.events.TextEvent.LINK, this.onBackToHellClickHandler);
            this._backToHell.autoSize = flash.text.TextFieldAutoSize.RIGHT;
            this._conditionPanel = new GuildEliteCopyCondition();
            this._conditionPanel.x = _left;
            this._conditionPanel.y = 50;
            _bodySp.addChild(this._conditionPanel);
            this._desc = ObjCreate.createGTextField("", _left, 70, 240, 20, _bodySp, GlobalStyle.setTextFormatLeading(GlobalStyle.textFormat5, 5));
            this._desc.mouseEnabled = false;
            this._desc.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._desc.wordWrap = true;
            this._desc.multiline = true;
            return;
        }

        public /* override */ updateInfos(arg1): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=arg1 as SGuildEliteCopyDetail;
            if (loc1) 
            {
                loc2 = CopyConfig.instance.getInfoByCode(loc1.copyCode);
                this._hellMapId = parseInt(loc2.maps.split("#")[0]);
                this._isHell = loc1.mapId == this._hellMapId;
                if (loc1.remainSeconds > 300) 
                {
                    this._time.defaultTextFormat = this._tfYel;
                }
                else 
                {
                    this._time.defaultTextFormat = this._tfRed;
                }
                this._time.setLeftTime(loc1.remainSeconds);
                if (this._isHell) 
                {
                    this._playerNum.htmlText = HTMLUtil.addColor(Language.getStringByParam(60618, loc1.playerNum, loc2.maxPlayer), "#FFFF00");
                    this._conditionPanel.updateData(true, loc1);
                    this._desc.htmlText = HTMLUtil.addColor(Language.getString(60622) + "\n" + loc2.introduction, "#FFFFFF");
                    DisplayUtil.removeMe(this._backToHell);
                }
                else 
                {
                    this._playerNum.htmlText = HTMLUtil.addColor(Language.getStringByParam(60623, loc1.playerNum), "#FFFF00");
                    this._conditionPanel.updateData(false, loc1);
                    if (loc3 = GuildEliteConfig.instance.getMap(loc2.code, loc1.mapId)) 
                    {
                        this._desc.htmlText = Language.getString(60636) + "\n" + loc3.showDrop;
                    }
                    _bodySp.addChild(this._backToHell);
                }
                this.updateSize();
            }
            return;
        }

        /* internal  */updateSize(): void
        {
            this._desc.y = this._conditionPanel.y + this._conditionPanel.height + 10;
            _bg.height = this._desc.y + this._desc.textHeight + 15;
            return;
        }

        /* internal  */onBackToHellClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=Cache.instance.scene.getPassPointByToMapId(this._hellMapId);
            if (loc1) 
            {
                AIManager.onAutoPathAIControl(loc1, AIType.AI_Scene);
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(60628));
            }
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            if (this._time) 
            {
                this._time.dispose();
            }
            if (this._conditionPanel) 
            {
                this._conditionPanel.dispose();
            }
            super.dispose();
            return;
        }

        /* internal */ /* var */_isHell: Boolean=true;

        /* internal */ /* var */_hellMapId: int;

        /* internal */ /* var */_time: SecTimerView;

        /* internal */ /* var */_playerNum: GTextFiled;

        /* internal */ /* var */_conditionPanel: GuildEliteCopyCondition;

        /* internal */ /* var */_backToHell: GTextFiled;

        /* internal */ /* var */_desc: GTextFiled;

        /* internal */ /* var */_tfYel: GTextFormat;

        /* internal */ /* var */_tfRed: GTextFormat;
    }
